home *** CD-ROM | disk | FTP | other *** search
/ Softwarová Záchrana 3 / Softwarova-zachrana-3.bin / Xteq X-Setup / xqdcXSP-Setup-EN.exe / {app} / plugins / svho IE ShowHide Context Menu.xpl < prev    next >
Text File  |  2003-11-19  |  7KB  |  231 lines

  1. "FILE"="Xteq Systems X-Setup Plugin 6.0"
  2. "TYPE"="9"
  3. "COUNT"="1"
  4. "UIPATH"="Internet\Internet Explorer\Context Menu Entries"
  5. "NAME"="Show/Hide Items"
  6. "LANGUAGE"="VBScript"
  7. "DESCRIPTION 1"="This plug-in shows or hides entries in Internet Explorer context menu. You may need to restart Internet Explorer to make it work."
  8. "DESCRIPTION 2"="NOTE #1: The name can include an ampersand (&) character, which will cause the character that follows to be underlined and used as a shortcut key."
  9. "DESCRIPTION 3"="NOTE #2: Plug-in lists useless entries (without default URL) too. IE makes this not!"
  10. "VERSION"="1.02"
  11. "AUTHOR"="Svyatoslav Holub"
  12. "CONTACTURL"="mailto:jobvonzuhause@everyday.com"
  13. "COPYRIGHT"="This plug-in is Freeware. Use at your own risk!"
  14. "COMMENT 1"="Tested on Windows 98SE with Internet Explorer 6.0"
  15. "ADMINRIGHTS"="0"
  16. "OSVERSION"="0111111"
  17.  
  18. visibleMenuExt="HKCU\Software\Microsoft\Internet Explorer\MenuExt"
  19. unvisibleMenuExt="HKCU\Software\Microsoft\Internet Explorer\MenuExt-"
  20.  
  21. dim visibleCount, unvisibleCount, visibleMenuExists, unvisibleMenuExists
  22. dim doubleElements()
  23.  
  24. Sub Plugin_Initialize
  25. 'Clear listbox
  26.  elemNumber = visibleCount + unvisibleCount
  27.  For l = 1 to elemNumber
  28.    SetUIElement l, ""
  29.  Next
  30.  
  31.  visibleCount = 0
  32.  unvisibleCount = 0
  33.  
  34.  
  35.  visibleMenuExists = RegPathExists(visibleMenuExt)
  36.  unvisibleMenuExists = RegPathExists(unvisibleMenuExt)
  37.  
  38.  If  visibleMenuExists = true Then
  39.   visibleCount=RegEnumPaths(visibleMenuExt)
  40.   If CBool (visibleCount) Then listAddNew visibleCount, 0, true
  41.  End If
  42.  
  43.  If  unvisibleMenuExists = true Then
  44.   unvisibleCount=RegEnumPaths(unvisibleMenuExt)
  45.   If CBool (unvisibleCount) Then listAddNew unvisibleCount, visibleCount, false
  46.  End If
  47.  
  48.  If visibleCount + unvisibleCount = 0 Then
  49.   SetUIElement 1, "No context menus are available!"
  50.   Disable
  51.  End If
  52. End Sub
  53.  
  54.  
  55. Sub Plugin_Apply(ElementIndex,ElementSubIndex)
  56. 'Nothing to do, if IE settings in Registry were meantime for example manual changed.
  57.  If RegistryChanged = true Then Exit Sub
  58.  
  59. 'Delete double entries.
  60.  If unvisibleCount > 0 Then
  61.    doubleCount = RegEnumPaths(unvisibleMenuExt)
  62.    Redim doubleElements(doubleCount)
  63.    For z=1 to doubleCount
  64.     unvElement = RegEnumElement(z)
  65.     If RegPathExists(visibleMenuExt & "\" & unvElement) = true Then
  66.       'to prevent out of bounds error by delete
  67.       doubleElements(z-1) = unvElement
  68.       unvisibleCount = unvisibleCount - 1
  69.     End If
  70.    Next
  71.    For n=0 to UBound(doubleElements)
  72.      If doubleElements(n)<>"" Then deleteSubKey unvisibleMenuExt & "\" & doubleElements(n)
  73.    Next
  74.  End If
  75.  
  76.  moveCounter = 0
  77.  For i=1 to visibleCount
  78.   If GetUIElementEx(i) = false Then 
  79.    moveSubKey GetUIElement(i), visibleMenuExt, unvisibleMenuExt
  80.    moveCounter = moveCounter + 1
  81.   End If
  82.  Next
  83.  
  84.  elemNumber = visibleCount + unvisibleCount
  85.  For i=visibleCount + 1 to elemNumber
  86.   If GetUIElementEx(i) = true Then
  87.    moveSubKey GetUIElement(i), unvisibleMenuExt, visibleMenuExt
  88.    moveCounter = moveCounter + 1
  89.   End If
  90.  Next
  91.  
  92.  If moveCounter = 0 Then
  93.   MsgInformation "No changes to apply!"
  94.  Else
  95.   IndicateSettingChange
  96.   Plugin_Initialize
  97.   MsgInformation "Your settings were applied."
  98.  End If
  99. End Sub
  100.  
  101.  
  102. Sub Plugin_Terminate
  103. End Sub
  104.  
  105.  
  106. Sub listAddNew (elemCounter, listCounter, visibilityFlag)
  107.  dim offset
  108.  For i=1 to elemCounter
  109.    extText=RegEnumElement(i)
  110.    If visibilityFlag = false Then
  111.  'hide double entries   
  112.     If RegPathExists(visibleMenuExt & "\" & extText) = true Then
  113.       offset = offset + 1
  114.     Else
  115.       j = i + listCounter - offset
  116.       SetUIElement j, extText
  117.           SetUIElementEx j, visibilityFlag
  118.         End If
  119.    Else
  120.        j = i + listCounter
  121.        SetUIElement j, extText
  122.        SetUIElementEx j, visibilityFlag
  123.    End If
  124.  Next
  125. End Sub
  126.  
  127.  
  128. Sub moveSubKey (Name, parentSourceKey, parentDestinationKey)
  129.   dim i, j
  130.   dim fullSourceKey, fullDestinationKey
  131.   dim pathsCount, valuesCount
  132.   dim defaultString, value, data, dataType
  133.    
  134.     fullSourceKey = parentSourceKey & "\" & Name
  135.     fullDestinationKey = parentDestinationKey & "\" & Name
  136.     
  137.     pathsCount = RegEnumPaths(fullSourceKey)
  138.     If pathsCount <> 0 Then
  139.       For j=1 to pathsCount
  140.        moveSubKey RegEnumElement(j), fullSourceKey, fullDestinationKey
  141.       Next
  142.     End If
  143.     
  144.     defaultString = RegReadValue(fullSourceKey & "\@")
  145.     RegWriteValue fullDestinationKey & "\@", defaultString, 1
  146.  
  147.     valuesCount = RegEnumValues(fullSourceKey)
  148.     For i=1 to valuesCount
  149.        value = RegEnumElement(i)
  150.        data = RegReadValue(fullSourceKey & "\" & value)
  151.        dataType = RegValueType(fullSourceKey & "\" & value)
  152.        RegWriteValue fullDestinationKey & "\" & value, data, dataType 
  153.        RegDeleteValue fullSourceKey & "\" & value
  154.     Next
  155.     RegDeletePath fullSourceKey
  156. End Sub
  157.  
  158.  
  159. Sub deleteSubKey (fullName)
  160.  dim x, y
  161.  dim values, pathsCount
  162.    pathsCount = RegEnumPaths(fullName)
  163.    If pathsCount <> 0 Then
  164.     For x=1 to pathsCount
  165.      deleteSubKey fullName & "\" & RegEnumElement(x)
  166.     Next
  167.    End If
  168.  
  169.    values = RegEnumValues(fullName)
  170.    For y=1 to values
  171.     valueName = RegEnumElement(y)
  172.     RegDeleteValue fullName & "\" & valueName
  173.    Next
  174.    RegDeletePath fullName
  175. End Sub
  176.  
  177. 'Check, if IE settings in Registry were meantime for example manual changed.
  178. 'If yes, plug-in restarts.
  179. Function RegistryChanged
  180.   If visibleMenuExists <> RegPathExists(visibleMenuExt) Then
  181.       IndicateSettingChange
  182.       RestartMessage
  183.       RegistryChanged = true
  184.       Exit Function
  185.   ElseIf visibleMenuExists = true Then
  186.       If visibleCount <> RegEnumPaths(visibleMenuExt) Then
  187.  IndicateSettingChange
  188.        RestartMessage
  189.        RegistryChanged = true
  190.        Exit Function
  191.       End If
  192.   End If
  193.   
  194.   If unvisibleMenuExists <> RegPathExists(unvisibleMenuExt) Then
  195.       RestartMessage
  196.       RegistryChanged = true
  197.       Exit Function
  198.   ElseIf unvisibleMenuExists = true Then
  199.       If unvisibleCount <> RegEnumPaths(unvisibleMenuExt) Then
  200.        RestartMessage
  201.        RegistryChanged = true
  202.        Exit Function
  203.       End If
  204.   End If
  205.  
  206.   For i=1 to visibleCount
  207.     If RegPathExists(visibleMenuExt & "\" & GetUIElement(i)) = false Then
  208.       IndicateSettingChange
  209.       RestartMessage
  210.       RegistryChanged = true
  211.       Exit Function
  212.     End If
  213.   Next
  214.  
  215.   elCount = visibleCount + unvisibleCount
  216.   For i=visibleCount + 1 to elCount
  217.     If RegPathExists(unvisibleMenuExt & "\" & GetUIElement(i)) = false Then
  218.       RestartMessage
  219.       RegistryChanged = true
  220.       Exit Function
  221.     End If
  222.   Next
  223.   
  224.   RegistryChanged = false
  225. End Function
  226.  
  227.  
  228. Sub RestartMessage
  229.   Plugin_Initialize
  230.   MsgWarning "Plug-in is restarted, because" & vbCrLf & "Registry was changed!" & vbCrLf & "Your settings were not applied."
  231. End Sub